package com.longge.wechat.controller.wx;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.longge.wechat.communication.Poster;
import com.longge.wechat.message.req.ReqTextMessage;
import com.longge.wechat.message.resp.RespTextMessage;
import com.longge.wechat.utils.SignUtil;
import com.longge.wechat.utils.XmlUtil;



@Controller
public class InformationController {
	
	@RequestMapping(value ="/information.do",method = RequestMethod.POST)
	public void information(HttpServletRequest request, HttpServletResponse response){
		String type = (String) request.getAttribute("type");
		String xmlText = (String) request.getAttribute("xmlText");
		String openId = (String) request.getAttribute("openId");
		String from =  (String) request.getAttribute("from");
		XmlUtil xmlUtil =XmlUtil.getInstance();
		
		String rs ="";
		
		
		
		RespTextMessage message = new RespTextMessage(openId,from, rs);
		Poster.post(response,XmlUtil.getInstance().bean2xml(message, null, null));
	}
	
	@RequestMapping(value ="/getInformation.do",method = RequestMethod.POST)
	public void getInformation(HttpServletRequest request, HttpServletResponse response){
		String openId = (String) request.getAttribute("openId");
		String from =  (String) request.getAttribute("from");
		
		//UserEntity  u = userServiceImpl.checkUser(openId);
		String rs  = "";
		String name = "真实姓名：\n";
		String tel="电话号码：\n";
		String address="收件地址：\n";
		rs ="您的个人信息如下\n"+name+address+tel;
		RespTextMessage message = new RespTextMessage(openId,from, rs);
		Poster.post(response,XmlUtil.getInstance().bean2xml(message, null, null));
	}
}
